﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExternalConnections.CUiECExternalConnectionsForm
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using C1.Win.C1FlexGrid;
using C1.Win.C1FlexGrid.Util.BaseControls;
using DnProcessSimulateCommands.ExternalConnections.Res;
using EngineeringInternalExtension;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Layout;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.ExternalConnections.Interfaces;
using Tecnomatix.Engineering.ExternalConnections.Runtime;
using Tecnomatix.Engineering.PrivateImplementationDetails;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.ExternalConnections;

public class CUiECExternalConnectionsForm : TxForm
{
  private const string RELATIVE_PATH_GRID_COLUMNS_WIDTH = "ColumnsWidth";
  private const string RELATIVE_PATH_GRID_SORT = "Sort";
  private const string SETTING_SORT_COLUMN_NAME = "SortColumn";
  private const string SETTING_SORT_COLUMN_TYPE = "SortType";
  private const string LOG_FILE_IMPORT_EXTENSION = ".txt";
  private const string LOG_FILE_IMPORT_SUFFIX = "_import";
  private const string LOG_FILE_IMPORT_DEFAULT_NAME = "OPC_Connections_import";
  private CApECExternalConnectionsManager m_dataMgr;
  private CUiECExternalConnectionsForm.PreservedSettings m_preservedSettings;
  private int m_suspendEnablersCounter;
  private IContainer components;
  private CUiECExternalConnectionsGridWrapper m_grid;
  private Button m_buttonImport;
  private Button m_buttonExport;
  private Button m_buttonValidate;
  private Button m_buttonRemove;
  private Button m_buttonEdit;
  private Button m_buttonAdd;
  private Button m_buttonOK;
  private Button m_buttonCancel;
  private ToolStripMenuItem m_OPCConnectionToolStripMenuItem;
  private ToolStripMenuItem m_SIMBAConnectionToolStripMenuItem;
  private TxContextMenuStrip m_connectionsMenuStrip;
  private ToolStripMenuItem m_OPCUAConnectionToolStripMenuItem;
  private ToolStripMenuItem m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem;
  private Button m_buttonSimulationSettings;
  private ToolStripMenuItem m_winModToolStripMenuItem;
  private ToolStripMenuItem m_simitCouplingToolStripMenuItem;

  public CApECExternalConnectionsManager ExternalConnectionsManager => this.m_dataMgr;

  public CUiECExternalConnectionsForm()
  {
    this.InitializeComponent();
    this.m_dataMgr = new CApECExternalConnectionsManager(this.m_grid);
    this.m_preservedSettings = this.CreateDefaultSettings();
    this.InitializeUserDefinedConnectionItems();
  }

  public virtual void OnInitTxForm()
  {
    base.OnInitTxForm();
    this.Initialize();
    ((ScrollableControl) this.m_grid).BeginUpdate();
    try
    {
      this.m_grid.ApplyColumnsWidthSettings(this.m_preservedSettings.GridSettings);
      this.LoadData();
      this.m_grid.ApplyColumnsSortSettings(this.m_preservedSettings.GridSettings);
    }
    finally
    {
      ((ScrollableControl) this.m_grid).EndUpdate();
    }
    this.m_buttonOK.Select();
  }

  private void Initialize()
  {
    if (!this.LoadPreservedSettings())
      this.m_preservedSettings = this.CreateDefaultSettings();
    this.m_dataMgr.Initialize();
    this.m_grid.Initialize();
    this.RegisterForEvents();
  }

  private void Uninitialize()
  {
    this.StorePreservedSettings();
    this.UnRegisterForEvents();
    this.m_dataMgr.UnInitialize();
    this.m_grid.Uninitialize();
  }

  private void RegisterForEvents() => this.RegisterForGridEvents();

  private void UnRegisterForEvents()
  {
    this.UnRegisterForGridEvents();
    this.UnitializeUserDefinedConnectionItems();
  }

  private void Userdefined_Click(object sender, EventArgs e)
  {
    this.CreateUserDefinedConnection((sender as ToolStripItem).Name);
  }

  private void CreateUserDefinedConnection(string guid)
  {
    txPlcConnConf = (ITxPlcConnConf) null;
    bool flag = false;
    try
    {
      // ISSUE: variable of a compiler-generated type
      PlcExtConnPluginFactory instance = (PlcExtConnPluginFactory) Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("169456D1-A3F3-4426-8D51-CA3131A50E34")));
      // ISSUE: reference to a compiler-generated method
      if (!(instance.CreateInstance(guid) is ITxPlcConnConf txPlcConnConf))
      {
        int num = (int) TxMessageBox.ShowModal(string.Format(CUiECExternalConnectionsResourceTable.ERR_MSG_MISSING_CONF_USER_DEFINED, (object) guid, (object) typeof (ITxPlcConnConf).ToString()), ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        flag = true;
      }
    }
    catch (Exception ex)
    {
      int num = (int) TxMessageBox.ShowModal(string.Format(CUiECExternalConnectionsResourceTable.ERR_MSG_USER_DEFINED_COM_NOT_REGISTRED, (object) guid), ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
      flag = true;
    }
    if (flag)
      return;
    this.SuspendUiEnablers();
    try
    {
      // ISSUE: explicit non-virtual call
      // ISSUE: reference to a compiler-generated method
      if (!txPlcConnConf.Setup(__nonvirtual (((Control) this).Handle)))
        return;
      TxPlcUserDefinedConnectionDataEx creationData = new TxPlcUserDefinedConnectionDataEx();
      creationData.Name = txPlcConnConf.Name;
      creationData.COMElement = guid;
      creationData.EndpointUrl = txPlcConnConf.State;
      CApECExternalConnectionsManager.eCreateConnectionFailiureReason failiureReason;
      if (!this.m_dataMgr.CanCreateConnectionWithData((ITxPlcExternalConnectionDataEx) creationData, out failiureReason))
      {
        if (failiureReason != CApECExternalConnectionsManager.eCreateConnectionFailiureReason.DuplicatedName)
        {
          if (failiureReason == CApECExternalConnectionsManager.eCreateConnectionFailiureReason.DuplicatedKey)
          {
            int num = (int) TxMessageBox.ShowModal(string.Format(CUiECExternalConnectionsResourceTable.ERR_MSG_DUPLICATED_KEY_USER_DEFINED, (object) guid), ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            return;
          }
        }
        else
        {
          int num = (int) TxMessageBox.ShowModal(CUiECExternalConnectionsResourceTable.ERR_MSG_DUPLICATED_CONNECTION_NAME, ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
          return;
        }
      }
      this.m_dataMgr.CreateConnection((ITxPlcExternalConnectionDataEx) creationData, out CApECExternalConnectionsManager.eCreateConnectionFailiureReason _);
    }
    catch (Exception ex)
    {
      int num = (int) TxMessageBox.ShowModal(string.Format(CUiECExternalConnectionsResourceTable.ERR_MSG_SETUP_EXCEPTION_USER_DEFINED, (object) guid) + Environment.NewLine + ex.Message, ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void UnitializeUserDefinedConnectionItems()
  {
    foreach (ToolStripItem toolStripItem in (ArrangedElementCollection) ((ToolStrip) this.m_connectionsMenuStrip).Items)
      toolStripItem.Click -= new EventHandler(this.Userdefined_Click);
  }

  private List<KeyValuePair<string, string>> GetCustomExternalConnections()
  {
    List<KeyValuePair<string, string>> externalConnections = new List<KeyValuePair<string, string>>();
    try
    {
      // ISSUE: variable of a compiler-generated type
      PlcExtConnPluginRegistry instance1 = (PlcExtConnPluginRegistry) Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("106C8337-C1BD-4214-8655-8CD137F80E4A")));
      // ISSUE: reference to a compiler-generated method
      string[] registeredPlugins = instance1.GetRegisteredPlugins();
      if (registeredPlugins.Length != 0)
      {
        // ISSUE: variable of a compiler-generated type
        PlcExtConnPluginFactory instance2 = (PlcExtConnPluginFactory) Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("169456D1-A3F3-4426-8D51-CA3131A50E34")));
        foreach (string str in registeredPlugins)
        {
          try
          {
            // ISSUE: reference to a compiler-generated method
            // ISSUE: variable of a compiler-generated type
            ITxPlcConn instance3 = instance2.CreateInstance(str) as ITxPlcConn;
            // ISSUE: variable of a compiler-generated type
            ITxPlcConnInfo txPlcConnInfo = instance3 as ITxPlcConnInfo;
            // ISSUE: variable of a compiler-generated type
            ITxPlcConnConf txPlcConnConf = instance3 as ITxPlcConnConf;
            if (instance3 == null || txPlcConnInfo == null || txPlcConnInfo == null)
              throw new Exception(CUiECExternalConnectionsResourceTable.NOT_SUPPORTED_INTERFACES);
            if (str == "{C9DDF8A6-9F8D-4AE9-B814-AB7D0C276883}")
            {
              if (TxFeatureManager.CheckFeature("KOLLMORGEN_CONNECTION"))
                externalConnections.Add(new KeyValuePair<string, string>(str, txPlcConnInfo.NiceName));
            }
            else
              externalConnections.Add(new KeyValuePair<string, string>(str, txPlcConnInfo.NiceName));
          }
          catch (Exception ex)
          {
          }
        }
      }
    }
    catch (Exception ex)
    {
    }
    return externalConnections;
  }

  private void InitializeUserDefinedConnectionItems()
  {
    foreach (KeyValuePair<string, string> externalConnection in this.GetCustomExternalConnections())
    {
      ToolStripItem toolStripItem = (ToolStripItem) new ToolStripMenuItem();
      toolStripItem.Text = externalConnection.Value;
      toolStripItem.Click += new EventHandler(this.Userdefined_Click);
      toolStripItem.Name = externalConnection.Key;
      ((ToolStrip) this.m_connectionsMenuStrip).Items.Insert(((ToolStrip) this.m_connectionsMenuStrip).Items.Count, toolStripItem);
    }
  }

  private void RegisterForGridEvents()
  {
    ((C1FlexGridBase) this.m_grid).AfterSelChange += new RangeEventHandler(this.m_grid_AfterSelChange);
    ((Control) this.m_grid).MouseDown += new MouseEventHandler(this.m_grid_MouseDown);
    ((Control) this.m_grid).KeyDown += new KeyEventHandler(this.m_grid_KeyDown);
    this.m_grid.CustomEditRequest += new CUiECExternalConnectionsGridWrapper.CustomEditRequestEventHandler(this.m_grid_CustomEditRequest);
  }

  private void UnRegisterForGridEvents()
  {
    ((C1FlexGridBase) this.m_grid).AfterSelChange -= new RangeEventHandler(this.m_grid_AfterSelChange);
    ((Control) this.m_grid).MouseDown -= new MouseEventHandler(this.m_grid_MouseDown);
    ((Control) this.m_grid).KeyDown -= new KeyEventHandler(this.m_grid_KeyDown);
    this.m_grid.CustomEditRequest -= new CUiECExternalConnectionsGridWrapper.CustomEditRequestEventHandler(this.m_grid_CustomEditRequest);
  }

  private bool EnablersSuspended() => this.m_suspendEnablersCounter > 0;

  private void SuspendUiEnablers() => ++this.m_suspendEnablersCounter;

  private void ResumeUiEnablers()
  {
    if (this.EnablersSuspended())
      --this.m_suspendEnablersCounter;
    if (this.EnablersSuspended())
      return;
    this.UpdateAllEnablers();
  }

  private void UpdateAllEnablers()
  {
    if (this.EnablersSuspended())
      return;
    this.UpdateEnablers_onGridSelection();
    this.UpdateEnablers_onConnectionsCount();
  }

  private void UpdateEnablers_onGridSelection()
  {
    if (this.EnablersSuspended())
      return;
    List<TxPlcExternalConnectionEx> selectedConnections = this.m_dataMgr.SelectedConnections;
    bool flag1 = selectedConnections.Count > 0;
    bool flag2 = selectedConnections.Count == 1;
    this.m_buttonValidate.Enabled = flag1;
    this.m_buttonRemove.Enabled = flag1;
    this.m_buttonEdit.Enabled = flag2;
  }

  private void UpdateEnablers_onConnectionsCount()
  {
    if (this.EnablersSuspended())
      return;
    this.m_buttonExport.Enabled = this.m_dataMgr.ExistConnectionNodes;
  }

  protected virtual void OnClosing(CancelEventArgs e)
  {
    this.Uninitialize();
    base.OnClosing(e);
  }

  private void m_buttonImport_Click(object sender, EventArgs e)
  {
    this.SuspendUiEnablers();
    try
    {
      CApECExternalConnectionsManager.ImportOutputParams importOutput;
      if (!this.m_dataMgr.ImportConnections(out importOutput))
      {
        if (TxMessageBox.ShowModal(CUiECExternalConnectionsResourceTable.IMPORT_FROM_EXCEL_FAIL, CUiECExternalConnectionsResourceTable.IMPORT_FROM_EXCEL_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Hand) != DialogResult.Yes)
          return;
        this.OpenImportLog(importOutput);
      }
      else
      {
        if (importOutput == null)
          return;
        if (importOutput.Warnings.Count > 0)
          this.OpenImportLog(importOutput);
        List<CApECBaseNode> nodes = new List<CApECBaseNode>();
        if (importOutput.ImportedNodes != null)
        {
          foreach (CApECExternalConnectionNode importedNode in importOutput.ImportedNodes)
            nodes.Add((CApECBaseNode) importedNode);
        }
        if (importOutput.ModifiedNodes != null)
        {
          foreach (CApECExternalConnectionNode modifiedNode in importOutput.ModifiedNodes)
            nodes.Add((CApECBaseNode) modifiedNode);
        }
        if (nodes.Count <= 0)
          return;
        this.m_grid.SelectNodes(nodes, true);
      }
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void m_buttonExport_Click(object sender, EventArgs e)
  {
    if (this.m_dataMgr.ExportConnections())
      return;
    int num = (int) TxMessageBox.ShowModal(CUiECExternalConnectionsResourceTable.EXPORT_TO_EXCEL_FAIL, CUiECExternalConnectionsResourceTable.EXPORT_TO_EXCEL_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Hand);
  }

  public void ValidateConnectionByName(
    string connectionName,
    out ValidateConnectionsOutputParams connectionParams)
  {
    connectionParams = (ValidateConnectionsOutputParams) null;
    this.m_dataMgr.ValidateExternalConnection(this.m_dataMgr.GetConnectionByName(connectionName), out connectionParams);
  }

  private void m_buttonValidate_Click(object sender, EventArgs e)
  {
    Cursor current = Cursor.Current;
    try
    {
      Cursor.Current = Cursors.WaitCursor;
      this.m_dataMgr.ValidateConnections(this.m_dataMgr.SelectedConnections);
    }
    finally
    {
      Cursor.Current = current;
    }
  }

  private void m_buttonRemove_Click(object sender, EventArgs e) => this.RemoveSelectedConnections();

  private void m_buttonEdit_Click(object sender, EventArgs e)
  {
    List<TxPlcExternalConnectionEx> selectedConnections = this.m_dataMgr.SelectedConnections;
    if (selectedConnections.Count != 1)
      return;
    this.OpenEditConnectionDialog(selectedConnections[0]);
  }

  private void m_buttonAdd_Click(object sender, EventArgs e)
  {
    Point position = new Point(0, this.m_buttonAdd.Height);
    ((Control) this.m_connectionsMenuStrip).Width = this.m_buttonAdd.Width;
    ((ToolStripDropDown) this.m_connectionsMenuStrip).Show((Control) this.m_buttonAdd, position);
  }

  private void m_buttonOK_Click(object sender, EventArgs e)
  {
    ((Form) this).DialogResult = DialogResult.OK;
    if (((Form) this).Modal)
      return;
    ((Form) this).Close();
  }

  private void m_buttonCancel_Click(object sender, EventArgs e)
  {
    ((Form) this).DialogResult = DialogResult.Cancel;
    if (((Form) this).Modal)
      return;
    ((Form) this).Close();
  }

  private void m_OPCConnectionToolStripMenuItem_Click(object sender, EventArgs e)
  {
    this.OpenAddOpcConnectionDialog();
  }

  private void m_SIMBAConnectionToolStripMenuItem_Click(object sender, EventArgs e)
  {
    this.OpenAddSimbaConnectionDialog();
  }

  private void m_OPCUAConnectionToolStripMenuItem_Click(object sender, EventArgs e)
  {
    this.OpenAddOPCUAConnectionDialog();
  }

  public CUiPLCSimAdvacnedConnection CreatePLCSimAdvacnedConnectionDialog()
  {
    CApECPLcSimAdvancedConnectionFormParams formParams = new CApECPLcSimAdvancedConnectionFormParams((IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor());
    CUiPLCSimAdvacnedConnection connectionDialog = new CUiPLCSimAdvacnedConnection(this.m_dataMgr);
    connectionDialog.InitMode(formParams);
    return connectionDialog;
  }

  public void ApplyPLCSIMAdvancedConnection(CUiPLCSimAdvacnedConnection editor)
  {
    CApECExternalConnectionNode connection = this.m_dataMgr.CreateConnection(editor.Params.DataToApply, out CApECExternalConnectionsManager.eCreateConnectionFailiureReason _);
    if (connection == null)
      return;
    this.m_grid.SelectNode((CApECBaseNode) connection, true);
    ((C1FlexGridBase) this.m_grid).Select(((RowCol) connection.Row).Index, 0, true);
  }

  private void m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem_Click(object sender, EventArgs e)
  {
    CApECPLcSimAdvancedConnectionFormParams formParams = new CApECPLcSimAdvancedConnectionFormParams((IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor());
    CUiPLCSimAdvacnedConnection editor = new CUiPLCSimAdvacnedConnection(this.m_dataMgr);
    if (editor.ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      this.ApplyPLCSIMAdvancedConnection(editor);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void m_buttonSimulationSettings_Click(object sender, EventArgs e)
  {
    ((Form) new CUiSimulationSettingsForm()).ShowDialog();
  }

  private void m_grid_AfterSelChange(object sender, RangeEventArgs e)
  {
    this.UpdateEnablers_onGridSelection();
  }

  private void m_grid_MouseDown(object sender, MouseEventArgs e)
  {
    if (e.Button != MouseButtons.Left)
      return;
    HitTestInfo hitTestInfo = ((C1FlexGridBase) this.m_grid).HitTest();
    if (((HitTestInfo) ref hitTestInfo).Type != null)
      return;
    this.SuspendUiEnablers();
    try
    {
      this.m_grid.ClearSelection();
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void m_grid_CustomEditRequest(
    object sender,
    CUiECExternalConnectionsGridWrapper.CustomEditRequestEventArgs e)
  {
    if (((RowColCollection) ((C1FlexGridBase) this.m_grid).Rows.Selected).Count != 1 || !this.m_buttonEdit.Enabled || !this.m_grid.IsConnectionNodeRow(e.Row))
      return;
    this.OpenEditConnectionDialog(this.m_grid.ConnectionNodeAt(e.Row).Connection);
    e.Handled = true;
  }

  private void m_grid_KeyDown(object sender, KeyEventArgs e)
  {
    if (e.KeyCode == Keys.Delete)
    {
      if (((RowColCollection) ((C1FlexGridBase) this.m_grid).Rows.Selected).Count <= 0 || !this.m_buttonRemove.Enabled)
        return;
      this.RemoveSelectedConnections();
    }
    else
    {
      if (Control.ModifierKeys != Keys.Control || e.KeyCode != Keys.A)
        return;
      this.SuspendUiEnablers();
      try
      {
        this.m_grid.SelectNodes(this.m_grid.Nodes, true);
      }
      finally
      {
        this.ResumeUiEnablers();
      }
    }
  }

  private void LoadData()
  {
    this.SuspendUiEnablers();
    try
    {
      this.m_dataMgr.Load();
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private bool LoadPreservedSettings() => this.LoadPreservedGridSettings();

  private bool LoadPreservedGridSettings()
  {
    CUiECExternalConnectionsGridWrapper.GridSettings gridSettings = this.m_preservedSettings.GridSettings;
    bool flag = true;
    try
    {
      string empty1 = string.Empty;
      string empty2 = string.Empty;
      string relativePath1 = "ColumnsWidth";
      Dictionary<string, int> columnNameToWidthMap = new Dictionary<string, int>();
      int result1 = -1;
      foreach (Column col in (IEnumerable) ((C1FlexGridBase) this.m_grid).Cols)
      {
        if (this.LoadStringSetting(col.Name, relativePath1, out empty2) && int.TryParse(empty2, out result1))
          columnNameToWidthMap.Add(col.Name, result1);
      }
      string relativePath2 = "Sort";
      string sortColumnName = string.Empty;
      SortFlags sortFlags = (SortFlags) 0;
      if (this.LoadStringSetting("SortColumn", relativePath2, out empty2))
        sortColumnName = empty2;
      if (this.LoadStringSetting("SortType", relativePath2, out empty2))
      {
        int result2 = -1;
        if (int.TryParse(empty2, out result2))
        {
          switch (result2)
          {
            case 0:
              sortFlags = (SortFlags) 1;
              break;
            case 1:
              sortFlags = (SortFlags) 2;
              break;
          }
        }
      }
      this.m_preservedSettings.GridSettings = new CUiECExternalConnectionsGridWrapper.GridSettings(columnNameToWidthMap, sortColumnName, sortFlags);
    }
    catch (Exception ex)
    {
      flag = false;
      this.m_preservedSettings.GridSettings = gridSettings;
    }
    return flag;
  }

  private bool StorePreservedSettings() => this.StorePreservedGridSettings();

  private bool StorePreservedGridSettings()
  {
    bool flag = true;
    try
    {
      this.m_preservedSettings.GridSettings = this.m_grid.RetrieveActualGridSettings();
      string empty1 = string.Empty;
      string empty2 = string.Empty;
      string empty3 = string.Empty;
      string relativePath1 = "ColumnsWidth";
      Dictionary<string, int>.Enumerator enumerator = this.m_preservedSettings.GridSettings.ColumnNameToWidthMap.GetEnumerator();
      while (enumerator.MoveNext())
      {
        KeyValuePair<string, int> current = enumerator.Current;
        string key = current.Key;
        current = enumerator.Current;
        int num = current.Value;
        if (!this.StoreStringSetting(key, relativePath1, num.ToString()))
          break;
      }
      string relativePath2 = "Sort";
      string sortColumnName = this.m_preservedSettings.GridSettings.SortColumnName;
      SortFlags sortFlags = this.m_preservedSettings.GridSettings.SortFlags;
      this.StoreStringSetting("SortColumn", relativePath2, sortColumnName);
      string name = "SortType";
      int num1 = -1;
      if ((sortFlags & 1) == 1)
        num1 = 0;
      else if ((sortFlags & 2) == 2)
        num1 = 1;
      this.StoreStringSetting(name, relativePath2, num1.ToString());
    }
    catch (Exception ex)
    {
      flag = false;
    }
    return flag;
  }

  private CUiECExternalConnectionsForm.PreservedSettings CreateDefaultSettings()
  {
    return new CUiECExternalConnectionsForm.PreservedSettings()
    {
      GridSettings = this.CreateDefaultGridSettings()
    };
  }

  private CUiECExternalConnectionsGridWrapper.GridSettings CreateDefaultGridSettings()
  {
    return new CUiECExternalConnectionsGridWrapper.GridSettings(new Dictionary<string, int>(), string.Empty, (SortFlags) 0);
  }

  private bool LoadStringSetting(string name, string relativePath, out string value)
  {
    bool flag = false;
    value = (string) null;
    object obj = (object) null;
    TxFormSettings.RestoreFormValue((Form) this, relativePath, name, ref obj);
    if (obj != null)
    {
      value = obj as string;
      if (value != null)
        flag = true;
    }
    return flag;
  }

  private bool StoreStringSetting(string name, string relativePath, string value)
  {
    bool flag = false;
    if (value != null)
    {
      TxFormSettings.StoreFormValue((Form) this, relativePath, name, value);
      flag = true;
    }
    return flag;
  }

  private void RemoveSelectedConnections()
  {
    this.SuspendUiEnablers();
    try
    {
      this.m_dataMgr.RemoveConnections(this.m_dataMgr.SelectedConnections);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void OpenEditConnectionDialog(TxPlcExternalConnectionEx connection)
  {
    if (connection.Data.ConnectionType == null)
      this.EditOpcConnection(connection);
    else if (connection.Data.ConnectionType == 2)
      this.EditOpcUAConnection(connection);
    else if (connection.Data.ConnectionType == 1)
      this.EditSimbaConnection(connection);
    else if (connection.Data.ConnectionType == 3)
      this.EditPlcSimAdvancedConnection(connection);
    else if (connection.Data.ConnectionType == 4)
      this.EditWinModConnection(connection);
    else if (connection.Data.ConnectionType == 5)
    {
      this.EditSimitCouplingConnection(connection);
    }
    else
    {
      if (connection.Data.ConnectionType != 6)
        return;
      this.EditUserDefinedConnection(connection);
    }
  }

  private void EditWinModConnection(TxPlcExternalConnectionEx connection)
  {
    ((Control) this).Cursor = Cursors.WaitCursor;
    IApECExternalConnectionDataConvertor dataConvertor = (IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor();
    CApECPLcWinModConnectionFormParams formParams = new CApECPLcWinModConnectionFormParams(connection, dataConvertor);
    if (new CUiPLCWinModConnection(this.m_dataMgr).ShowDialog(formParams) == DialogResult.OK)
    {
      this.SuspendUiEnablers();
      try
      {
        this.m_dataMgr.SetConnectionData(formParams.ConnectionToEdit, formParams.DataToApply, out CApECExternalConnectionsManager.eSetConnectionDataFailiureReason _);
      }
      finally
      {
        this.ResumeUiEnablers();
      }
    }
    ((Control) this).Cursor = Cursors.Default;
  }

  private void EditPlcSimAdvancedConnection(TxPlcExternalConnectionEx connection)
  {
    ((Control) this).Cursor = Cursors.WaitCursor;
    IApECExternalConnectionDataConvertor dataConvertor = (IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor();
    CApECPLcSimAdvancedConnectionFormParams formParams = new CApECPLcSimAdvancedConnectionFormParams(connection, dataConvertor);
    if (new CUiPLCSimAdvacnedConnection(this.m_dataMgr).ShowDialog(formParams) == DialogResult.OK)
    {
      this.SuspendUiEnablers();
      try
      {
        this.m_dataMgr.SetConnectionData(formParams.ConnectionToEdit, formParams.DataToApply, out CApECExternalConnectionsManager.eSetConnectionDataFailiureReason _);
      }
      finally
      {
        this.ResumeUiEnablers();
      }
    }
    ((Control) this).Cursor = Cursors.Default;
  }

  private void EditOpcConnection(TxPlcExternalConnectionEx connection)
  {
    IApECExternalConnectionDataConvertor dataConvertor = (IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor();
    CApECOpcConnectionFormParams formParams = new CApECOpcConnectionFormParams(connection, dataConvertor);
    if (new CUiECEditOpcConnectionForm(this.m_dataMgr).ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      this.m_dataMgr.SetConnectionData(formParams.ConnectionToEdit, formParams.DataToApply, out CApECExternalConnectionsManager.eSetConnectionDataFailiureReason _);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void EditOpcUAConnection(TxPlcExternalConnectionEx connection)
  {
    IApECExternalConnectionDataConvertor dataConvertor = (IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor();
    CApECOpcUAConnectionFormParams formParams = new CApECOpcUAConnectionFormParams(connection, dataConvertor);
    if (new CUiCOpcUAConnectionForm(this.m_dataMgr).ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      this.m_dataMgr.SetConnectionData(formParams.ConnectionToEdit, formParams.DataToApply, out CApECExternalConnectionsManager.eSetConnectionDataFailiureReason _);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void EditSimbaConnection(TxPlcExternalConnectionEx connection)
  {
    IApECExternalConnectionDataConvertor dataConvertor = (IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor();
    CApECSimbaConnectionFormParams formParams = new CApECSimbaConnectionFormParams(connection, dataConvertor);
    if (new CUiECEditSimbaPnioConnectionForm(this.m_dataMgr).ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      this.m_dataMgr.SetConnectionData(formParams.ConnectionToEdit, formParams.DataToApply, out CApECExternalConnectionsManager.eSetConnectionDataFailiureReason _);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void EditUserDefinedConnection(TxPlcExternalConnectionEx connection)
  {
    string comElement = ((TxPlcUserDefinedConnectionDataEx) connection.Data).COMElement;
    txPlcConnConf = (ITxPlcConnConf) null;
    bool flag = false;
    try
    {
      // ISSUE: variable of a compiler-generated type
      PlcExtConnPluginFactory instance = (PlcExtConnPluginFactory) Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("169456D1-A3F3-4426-8D51-CA3131A50E34")));
      // ISSUE: reference to a compiler-generated method
      if (instance.CreateInstance(comElement) is ITxPlcConnConf txPlcConnConf)
      {
        txPlcConnConf.Name = connection.Data.Name;
        txPlcConnConf.State = ((TxPlcUserDefinedConnectionDataEx) connection.Data).EndpointUrl;
      }
      else
      {
        int num = (int) TxMessageBox.ShowModal(string.Format(CUiECExternalConnectionsResourceTable.ERR_MSG_MISSING_CONF_USER_DEFINED, (object) comElement, (object) typeof (ITxPlcConnConf).ToString()), ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        flag = true;
      }
    }
    catch
    {
      int num = (int) TxMessageBox.ShowModal(string.Format(CUiECExternalConnectionsResourceTable.ERR_MSG_USER_DEFINED_COM_NOT_REGISTRED, (object) comElement), ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
      flag = true;
    }
    if (flag)
      return;
    this.SuspendUiEnablers();
    try
    {
      // ISSUE: explicit non-virtual call
      // ISSUE: reference to a compiler-generated method
      if (!txPlcConnConf.Setup(__nonvirtual (((Control) this).Handle)))
        return;
      this.m_dataMgr.SetConnectionData(connection, (ITxPlcExternalConnectionDataEx) new TxPlcUserDefinedConnectionDataEx((TxPlcUserDefinedConnectionDataEx) connection.Data)
      {
        Name = txPlcConnConf.Name,
        EndpointUrl = txPlcConnConf.State
      }, out CApECExternalConnectionsManager.eSetConnectionDataFailiureReason _);
    }
    catch (Exception ex)
    {
      int num = (int) TxMessageBox.ShowModal(string.Format(CUiECExternalConnectionsResourceTable.ERR_MSG_SETUP_EXCEPTION_USER_DEFINED, (object) comElement) + Environment.NewLine + ex.Message, ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void EditSimitCouplingConnection(TxPlcExternalConnectionEx connection)
  {
    ((Control) this).Cursor = Cursors.WaitCursor;
    CApECExternalConnectionDataEditConvertor dataConvertor = new CApECExternalConnectionDataEditConvertor();
    CApECPLCSimitCouplingConnectionFormParams formParams = new CApECPLCSimitCouplingConnectionFormParams(connection, (IApECExternalConnectionDataConvertor) dataConvertor);
    if (new CUiPLCSimitCouplingConnectionForm(this.m_dataMgr).ShowDialog(formParams) == DialogResult.OK)
    {
      this.SuspendUiEnablers();
      try
      {
        this.m_dataMgr.SetConnectionData(formParams.ConnectionToEdit, formParams.DataToApply, out CApECExternalConnectionsManager.eSetConnectionDataFailiureReason _);
      }
      finally
      {
        this.ResumeUiEnablers();
      }
    }
    ((Control) this).Cursor = Cursors.Default;
  }

  private void OpenAddSimbaConnectionDialog()
  {
    CApECSimbaConnectionFormParams formParams = new CApECSimbaConnectionFormParams((IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor());
    if (new CUiECEditSimbaPnioConnectionForm(this.m_dataMgr).ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      CApECExternalConnectionNode connection = this.m_dataMgr.CreateConnection(formParams.DataToApply, out CApECExternalConnectionsManager.eCreateConnectionFailiureReason _);
      if (connection == null)
        return;
      this.m_grid.SelectNode((CApECBaseNode) connection, true);
      ((C1FlexGridBase) this.m_grid).Select(((RowCol) connection.Row).Index, 0, true);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void OpenAddOpcConnectionDialog()
  {
    CApECOpcConnectionFormParams formParams = new CApECOpcConnectionFormParams((IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor());
    if (new CUiECEditOpcConnectionForm(this.m_dataMgr).ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      CApECExternalConnectionNode connection = this.m_dataMgr.CreateConnection(formParams.DataToApply, out CApECExternalConnectionsManager.eCreateConnectionFailiureReason _);
      if (connection == null)
        return;
      this.m_grid.SelectNode((CApECBaseNode) connection, true);
      ((C1FlexGridBase) this.m_grid).Select(((RowCol) connection.Row).Index, 0, true);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  public void OpenAddOPCUAConnectionDialog()
  {
    CApECOpcUAConnectionFormParams formParams = new CApECOpcUAConnectionFormParams((IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor());
    if (new CUiCOpcUAConnectionForm(this.m_dataMgr).ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      CApECExternalConnectionNode connection = this.m_dataMgr.CreateConnection(formParams.DataToApply, out CApECExternalConnectionsManager.eCreateConnectionFailiureReason _);
      if (connection == null)
        return;
      this.m_grid.SelectNode((CApECBaseNode) connection, true);
      ((C1FlexGridBase) this.m_grid).Select(((RowCol) connection.Row).Index, 0, true);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void OpenImportLog(
    CApECExternalConnectionsManager.ImportOutputParams importOutput)
  {
    string fromExcelCaption = CUiECExternalConnectionsResourceTable.IMPORT_FROM_EXCEL_CAPTION;
    string str1 = importOutput.FilePath == null || importOutput.FilePath.Length <= 0 ? TxApplication.CurrentUserDirectory + "OPC_Connections_import.txt" : importOutput.FilePath + "_import.txt";
    bool flag = false;
    try
    {
      string logFileDescription = CUiECExternalConnectionsResourceTable.LOG_FILE_DESCRIPTION;
      string upper1 = CUiECExternalConnectionsResourceTable.LOG_FILE_NOTIFICATIONS.ToUpper();
      string upper2 = CUiECExternalConnectionsResourceTable.LOG_FILE_WARNINGS.ToUpper();
      string upper3 = CUiECExternalConnectionsResourceTable.LOG_FILE_ERRORS.ToUpper();
      string format1 = CUiECExternalConnectionsResourceTable.LOG_FILE_SUCCESS_SUMMARYIES;
      if (importOutput.Warnings.Count == 1)
        format1 = CUiECExternalConnectionsResourceTable.LOG_FILE_SUCCESS_SUMMARY;
      if (importOutput.ImportFailed)
        format1 = importOutput.Errors.Count <= 1 ? CUiECExternalConnectionsResourceTable.LOG_FILE_FAIL_SUMMARY : CUiECExternalConnectionsResourceTable.LOG_FILE_FAIL_SUMMARYIES;
      string str2 = "\t";
      string newLine = Environment.NewLine;
      string format2 = "{0}" + newLine;
      string format3 = $"{{0}}{{1}}{newLine}";
      string format4 = $"{{0}}{{1}}{{2}}{newLine}";
      string str3 = new string('=', 32 /*0x20*/);
      string empty1 = string.Empty;
      string empty2 = string.Empty;
      string empty3 = string.Empty;
      int count1 = importOutput.Notifications != null ? importOutput.Notifications.Count : 0;
      int count2 = importOutput.Warnings != null ? importOutput.Warnings.Count : 0;
      int count3 = importOutput.Errors != null ? importOutput.Errors.Count : 0;
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.AppendFormat(format2, (object) logFileDescription);
      stringBuilder.AppendFormat(format3, (object) str2, (object) str1);
      stringBuilder.AppendFormat(format4, (object) str3, (object) upper1, (object) str3);
      if (count1 > 0)
      {
        foreach (string notification in importOutput.Notifications)
          stringBuilder.AppendFormat(format2, (object) notification);
      }
      stringBuilder.AppendFormat(format4, (object) str3, (object) upper2, (object) str3);
      if (count2 > 0)
      {
        foreach (string warning in importOutput.Warnings)
          stringBuilder.AppendFormat(format2, (object) warning);
      }
      stringBuilder.AppendFormat(format4, (object) str3, (object) upper3, (object) str3);
      if (count3 > 0)
      {
        foreach (string error in importOutput.Errors)
          stringBuilder.AppendFormat(format2, (object) error);
      }
      string str4 = string.Format(format1, (object) count3, (object) count2);
      stringBuilder.AppendFormat(format3, (object) str2, (object) str4);
      StreamWriter streamWriter = new StreamWriter((Stream) new FileStream(str1, FileMode.Create));
      streamWriter.Write(stringBuilder.ToString());
      streamWriter.Flush();
      streamWriter.Close();
    }
    catch (Exception ex)
    {
      int num = (int) TxMessageBox.ShowModal(CUiECExternalConnectionsResourceTable.LOG_FILE_FAIL_TO_CREATE_FILE, fromExcelCaption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
      flag = true;
    }
    if (flag)
      return;
    try
    {
      Process.Start(str1);
    }
    catch (Exception ex)
    {
      int num = (int) TxMessageBox.ShowModal(CUiECExternalConnectionsResourceTable.LOG_FILE_FAIL_TO_SHOW_FILE, fromExcelCaption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
  }

  private void winModToolStripMenuItem_Click(object sender, EventArgs e)
  {
    CApECPLcWinModConnectionFormParams formParams = new CApECPLcWinModConnectionFormParams((IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor());
    if (new CUiPLCWinModConnection(this.m_dataMgr).ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      CApECExternalConnectionNode connection = this.m_dataMgr.CreateConnection(formParams.DataToApply, out CApECExternalConnectionsManager.eCreateConnectionFailiureReason _);
      if (connection == null)
        return;
      this.m_grid.SelectNode((CApECBaseNode) connection, true);
      ((C1FlexGridBase) this.m_grid).Select(((RowCol) connection.Row).Index, 0, true);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void simitCouplingToolStripMenuItem_Click(object sender, EventArgs e)
  {
    CApECPLCSimitCouplingConnectionFormParams formParams = new CApECPLCSimitCouplingConnectionFormParams((IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataEditConvertor());
    if (new CUiPLCSimitCouplingConnectionForm(this.m_dataMgr).ShowDialog(formParams) != DialogResult.OK)
      return;
    this.SuspendUiEnablers();
    try
    {
      CApECExternalConnectionNode connection = this.m_dataMgr.CreateConnection(formParams.DataToApply, out CApECExternalConnectionsManager.eCreateConnectionFailiureReason _);
      if (connection == null)
        return;
      this.m_grid.SelectNode((CApECBaseNode) connection, true);
      ((C1FlexGridBase) this.m_grid).Select(((RowCol) connection.Row).Index, 0, true);
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    this.components = (IContainer) new Container();
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUiECExternalConnectionsForm));
    this.m_buttonImport = new Button();
    this.m_buttonExport = new Button();
    this.m_buttonValidate = new Button();
    this.m_buttonRemove = new Button();
    this.m_buttonEdit = new Button();
    this.m_buttonAdd = new Button();
    this.m_buttonOK = new Button();
    this.m_buttonCancel = new Button();
    this.m_OPCConnectionToolStripMenuItem = new ToolStripMenuItem();
    this.m_SIMBAConnectionToolStripMenuItem = new ToolStripMenuItem();
    this.m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem = new ToolStripMenuItem();
    this.m_connectionsMenuStrip = new TxContextMenuStrip(this.components);
    this.m_OPCUAConnectionToolStripMenuItem = new ToolStripMenuItem();
    this.m_winModToolStripMenuItem = new ToolStripMenuItem();
    this.m_simitCouplingToolStripMenuItem = new ToolStripMenuItem();
    this.m_buttonSimulationSettings = new Button();
    this.m_grid = new CUiECExternalConnectionsGridWrapper();
    Label label = new Label();
    ((Control) this.m_connectionsMenuStrip).SuspendLayout();
    ((ISupportInitialize) this.m_grid).BeginInit();
    ((Control) this).SuspendLayout();
    componentResourceManager.ApplyResources((object) label, "bottomSeparator");
    label.BorderStyle = BorderStyle.FixedSingle;
    label.Name = "bottomSeparator";
    componentResourceManager.ApplyResources((object) this.m_buttonImport, "m_buttonImport");
    this.m_buttonImport.Name = "m_buttonImport";
    this.m_buttonImport.UseVisualStyleBackColor = true;
    this.m_buttonImport.Click += new EventHandler(this.m_buttonImport_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonExport, "m_buttonExport");
    this.m_buttonExport.Name = "m_buttonExport";
    this.m_buttonExport.UseVisualStyleBackColor = true;
    this.m_buttonExport.Click += new EventHandler(this.m_buttonExport_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonValidate, "m_buttonValidate");
    this.m_buttonValidate.Name = "m_buttonValidate";
    this.m_buttonValidate.UseVisualStyleBackColor = true;
    this.m_buttonValidate.Click += new EventHandler(this.m_buttonValidate_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonRemove, "m_buttonRemove");
    this.m_buttonRemove.Name = "m_buttonRemove";
    this.m_buttonRemove.UseVisualStyleBackColor = true;
    this.m_buttonRemove.Click += new EventHandler(this.m_buttonRemove_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonEdit, "m_buttonEdit");
    this.m_buttonEdit.Name = "m_buttonEdit";
    this.m_buttonEdit.UseVisualStyleBackColor = true;
    this.m_buttonEdit.Click += new EventHandler(this.m_buttonEdit_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonAdd, "m_buttonAdd");
    this.m_buttonAdd.Name = "m_buttonAdd";
    this.m_buttonAdd.UseVisualStyleBackColor = true;
    this.m_buttonAdd.Click += new EventHandler(this.m_buttonAdd_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonOK, "m_buttonOK");
    this.m_buttonOK.Name = "m_buttonOK";
    this.m_buttonOK.UseVisualStyleBackColor = true;
    this.m_buttonOK.Click += new EventHandler(this.m_buttonOK_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonCancel, "m_buttonCancel");
    this.m_buttonCancel.DialogResult = DialogResult.Cancel;
    this.m_buttonCancel.Name = "m_buttonCancel";
    this.m_buttonCancel.UseVisualStyleBackColor = true;
    this.m_buttonCancel.Click += new EventHandler(this.m_buttonCancel_Click);
    this.m_OPCConnectionToolStripMenuItem.Name = "m_OPCConnectionToolStripMenuItem";
    componentResourceManager.ApplyResources((object) this.m_OPCConnectionToolStripMenuItem, "m_OPCConnectionToolStripMenuItem");
    this.m_OPCConnectionToolStripMenuItem.Click += new EventHandler(this.m_OPCConnectionToolStripMenuItem_Click);
    this.m_SIMBAConnectionToolStripMenuItem.Name = "m_SIMBAConnectionToolStripMenuItem";
    componentResourceManager.ApplyResources((object) this.m_SIMBAConnectionToolStripMenuItem, "m_SIMBAConnectionToolStripMenuItem");
    this.m_SIMBAConnectionToolStripMenuItem.Click += new EventHandler(this.m_SIMBAConnectionToolStripMenuItem_Click);
    this.m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem.Name = "m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem";
    componentResourceManager.ApplyResources((object) this.m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem, "m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem");
    this.m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem.Click += new EventHandler(this.m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem_Click);
    ((ToolStrip) this.m_connectionsMenuStrip).Items.AddRange(new ToolStripItem[6]
    {
      (ToolStripItem) this.m_OPCConnectionToolStripMenuItem,
      (ToolStripItem) this.m_OPCUAConnectionToolStripMenuItem,
      (ToolStripItem) this.m_SIMBAConnectionToolStripMenuItem,
      (ToolStripItem) this.m_PLCSIMAdvancedRemoteConnectionToolStripMenuItem,
      (ToolStripItem) this.m_winModToolStripMenuItem,
      (ToolStripItem) this.m_simitCouplingToolStripMenuItem
    });
    ((Control) this.m_connectionsMenuStrip).Name = "m_connectionsMenuStrip";
    ((ToolStripDropDownMenu) this.m_connectionsMenuStrip).ShowImageMargin = false;
    componentResourceManager.ApplyResources((object) this.m_connectionsMenuStrip, "m_connectionsMenuStrip");
    this.m_OPCUAConnectionToolStripMenuItem.Name = "m_OPCUAConnectionToolStripMenuItem";
    componentResourceManager.ApplyResources((object) this.m_OPCUAConnectionToolStripMenuItem, "m_OPCUAConnectionToolStripMenuItem");
    this.m_OPCUAConnectionToolStripMenuItem.Click += new EventHandler(this.m_OPCUAConnectionToolStripMenuItem_Click);
    this.m_winModToolStripMenuItem.Name = "m_winModToolStripMenuItem";
    componentResourceManager.ApplyResources((object) this.m_winModToolStripMenuItem, "m_winModToolStripMenuItem");
    this.m_winModToolStripMenuItem.Click += new EventHandler(this.winModToolStripMenuItem_Click);
    this.m_simitCouplingToolStripMenuItem.Name = "m_simitCouplingToolStripMenuItem";
    componentResourceManager.ApplyResources((object) this.m_simitCouplingToolStripMenuItem, "m_simitCouplingToolStripMenuItem");
    this.m_simitCouplingToolStripMenuItem.Click += new EventHandler(this.simitCouplingToolStripMenuItem_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonSimulationSettings, "m_buttonSimulationSettings");
    this.m_buttonSimulationSettings.Name = "m_buttonSimulationSettings";
    this.m_buttonSimulationSettings.UseVisualStyleBackColor = true;
    this.m_buttonSimulationSettings.Click += new EventHandler(this.m_buttonSimulationSettings_Click);
    ((C1FlexGridBase) this.m_grid).AllowDragging = (AllowDraggingEnum) 0;
    componentResourceManager.ApplyResources((object) this.m_grid, "m_grid");
    ((ScrollableControl) this.m_grid).BorderStyle = (BorderStyleEnum) 0;
    ((C1FlexGridBase) this.m_grid).EmptyAsNull = false;
    ((C1FlexGridBase) this.m_grid).ExtendLastCol = true;
    ((C1FlexGridBase) this.m_grid).HighLight = (HighLightEnum) 0;
    ((Control) this.m_grid).Name = "m_grid";
    ((RowColCollection) ((C1FlexGridBase) this.m_grid).Rows).Count = 1;
    ((RowColCollection) ((C1FlexGridBase) this.m_grid).Rows).DefaultSize = 19;
    ((C1FlexGridBase) this.m_grid).SelectionMode = (SelectionModeEnum) 7;
    ((C1FlexGridBase) this.m_grid).StyleInfo = componentResourceManager.GetString("m_grid.StyleInfo");
    ((Form) this).AcceptButton = (IButtonControl) this.m_buttonOK;
    componentResourceManager.ApplyResources((object) this, "$this");
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Form) this).CancelButton = (IButtonControl) this.m_buttonCancel;
    ((Control) this).Controls.Add((Control) this.m_buttonSimulationSettings);
    ((Control) this).Controls.Add((Control) label);
    ((Control) this).Controls.Add((Control) this.m_buttonCancel);
    ((Control) this).Controls.Add((Control) this.m_buttonOK);
    ((Control) this).Controls.Add((Control) this.m_buttonAdd);
    ((Control) this).Controls.Add((Control) this.m_buttonEdit);
    ((Control) this).Controls.Add((Control) this.m_buttonRemove);
    ((Control) this).Controls.Add((Control) this.m_buttonValidate);
    ((Control) this).Controls.Add((Control) this.m_buttonExport);
    ((Control) this).Controls.Add((Control) this.m_buttonImport);
    ((Control) this).Controls.Add((Control) this.m_grid);
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUiECExternalConnectionsForm);
    this.SemiModal = false;
    ((Form) this).SizeGripStyle = SizeGripStyle.Hide;
    ((Control) this.m_connectionsMenuStrip).ResumeLayout(false);
    ((ISupportInitialize) this.m_grid).EndInit();
    ((Control) this).ResumeLayout(false);
  }

  private class PreservedSettings
  {
    internal CUiECExternalConnectionsGridWrapper.GridSettings GridSettings;
  }
}
